function isWeChat () {
  var ua = navigator.userAgent.toLowerCase()
  if (ua.match(/MicroMessenger/i) === 'micromessenger') {
    return true
  }
  return false
}

function isQQ () {
  var ua = navigator.userAgent.toLowerCase()
  if (ua.match(/QQ/i) === 'qq') {
    return true
  }
  return false
}

function isMobile () {
  const platform = getPlatform()
  return platform === 'iOS' || platform === 'Android'
}

function getPlatform () {
  if (/(Android)/i.test(navigator.userAgent)) { // 移动端-Android
    return 'Android'
  } else if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { // 移动端-iOS
    return 'iOS'
  } else {
    return 'PC'
  }
}

export default {
  isWeChat,
  isQQ,
  isMobile,
  getPlatform
}
